<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/27
 * Time: 16:06
 */
namespace app\api\model;

class User extends BaseModel {

    protected $autoWriteTimestamp = true;

    public function address(){
        return $this->hasOne('UserAddress','user_id','id');
    }

    public static function getUserAddress(){
        return self::with(['address'])->find();
    }

    public static function getByOpenId($openId){
        return self::get(['openid'=>$openId]);
    }

}